<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('餐厅菜单列表')"/>
    <style>
        .img-circle {
            border-radius: 10%;
        }
    </style>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="add()" shiro:hasPermission="wechat:WxCanteenMenu:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <input type="hidden" id="cid" th:value="${cid}"/>
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('wechat:WxCanteenMenu:edit')}]];
    var removeFlag = [[${@permission.hasPermi('wechat:WxCanteenMenu:remove')}]];
    var prefix = ctx + "wechat/WxCanteenMenu";

    $(function () {
        var options = {
            url: prefix + "/list?menuCid=" + $("#cid").val(),
            detailUrl: prefix + "/detail/{id}",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "餐厅菜单",
            columns: [
                {
                    field: 'menuId',
                    title: '编号',
                    visible: false,
                    sortable: false
                },
                {
                    field: 'menuPic',
                    title: '菜品图片',
                    sortable: false,
                    formatter: function (value, row, index) {
                        return $.table.imageView(value, 200);
                    }
                },
                {
                    field: 'menuName',
                    title: '菜品名称',
                    sortable: false
                },

                {
                    field: 'menuUnit',
                    title: '单位',
                    sortable: false
                },
                {
                    field: 'menuPrice',
                    title: '菜品价格',
                    sortable: false
                },
                {
                    field: 'menuSort',
                    title: '排序',
                    sortable: false
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="edit(\'' + row.menuId + '\')">编辑</a> ');
                        actions.push('<a class="btn btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.menuId + '\')">删除</a>');
                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });
    function add(){
        $.modal.open("添加菜品", prefix + "/add?cid=" + $("#cid").val(),500,600);
    }
    function edit(id){
        $.modal.open("编辑菜品", prefix + "/edit/" + id,500,600);
    }
</script>
</body>
</html>
